package com.freewater.springboot.demo.aop.advice.generic;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class);
        applicationContext.registerShutdownHook();
        final PersonService personService = applicationContext.getBean(PersonService.class);
        final Person person = personService.addPerson("zhang", 10);
        personService.describe(person); // 会被拦截
        //
        final UserService userService = applicationContext.getBean(UserService.class);
        final User user = userService.addUser("lisi", 10);
        userService.describe(user);// 不会被拦截
        //
        final List<Person> persons = new ArrayList<>();
        persons.add(person);
        personService.describeCollection(persons);// 会被拦截
        //
        final List<User> users = new ArrayList<>();
        users.add(user);
        userService.describeCollection(users);// 会被拦截
    }
}
